package com.xyht.sca_s.student_manage_system.modules.meeting.controller;


import com.xyht.sca_s.student_manage_system.common.commonReturn.ResponseResult;
import com.xyht.sca_s.student_manage_system.common.desEncodeAndDecode.annotation.SecretBody;
import com.xyht.sca_s.student_manage_system.modules.meeting.entity.req.MeetingRoomIdReq;
import com.xyht.sca_s.student_manage_system.modules.meeting.entity.req.SmsMeetingRoomInfoReq;
import com.xyht.sca_s.student_manage_system.modules.meeting.service.SmsMeetingRoomInfoService;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * <p>
 * 会议室信息表 前端控制器
 * </p>
 *
 * @author XYHT
 * @since 2023-08-03
 */
@RestController
@SecretBody
@RequestMapping("/meetingRoom")
public class SmsMeetingRoomInfoController {
    @Resource
    private SmsMeetingRoomInfoService smsMeetingRoomInfoService;

    @ApiModelProperty(value = "添加会议室")
    @PostMapping("/addRoom")
    public ResponseResult addMeetingRoom(@RequestBody SmsMeetingRoomInfoReq meetingRoomReq) {
        return smsMeetingRoomInfoService.addMeetingRoom(meetingRoomReq);
    }

    @ApiModelProperty(value = "删除会议室")
    @PostMapping("/deleteRoom")
    public ResponseResult deleteMeetingRoom(@RequestBody MeetingRoomIdReq idReq) {
        return smsMeetingRoomInfoService.deleteMeetingRoom(idReq.getId());
    }

    @ApiModelProperty(value = "编辑会议室")
    @PostMapping("/updateRoom")
    public ResponseResult updateMeetingRoom(@RequestBody SmsMeetingRoomInfoReq meetingRoomReq) {
        return smsMeetingRoomInfoService.updateMeetingRoom(meetingRoomReq);
    }

    @ApiModelProperty(value = "展示会议室")
    @GetMapping("/listRoom")
    public ResponseResult listMeetingRoom(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
                                          @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
                                          @RequestParam(value = "orgId", required = false) String orgId,
                                          @RequestParam(value = "buildingId", required = false) String buildingId,
                                          @RequestParam(value = "floorId", required = false) String floorId,
                                          @RequestParam(value = "searchStr", required = false) String searchStr) {
        return smsMeetingRoomInfoService.listMeetingRoom(pageNum, pageSize, orgId, buildingId, floorId, searchStr);
    }

    @ApiModelProperty(value = "展示规定时间段可用会议室")
    @GetMapping("/listUsableRoom")
    public ResponseResult listUsableMeetingRoom(@RequestParam(value = "startDate") Date startDate,
                                                @RequestParam(value = "endDate") Date endDate,
                                                @RequestParam(value = "repeatType") Integer repeatType,
                                                @RequestParam(value = "repeatEndTime", required = false) Date repeatEndTime,
                                                @RequestParam(value = "repeatCustomWeek", required = false) List<Integer> repeatCustomWeek,
                                                @RequestParam(value = "device", required = false) List<String> deviceList,
                                                @RequestParam(value = "capacity", required = false) Integer capacity,
                                                @RequestParam(value = "searchStr", required = false) String searchStr) {
        return smsMeetingRoomInfoService.listUsableMeetingRoom(startDate, endDate, repeatType, repeatEndTime, repeatCustomWeek, deviceList, capacity, searchStr);
    }
}

